package sk.naive.talker.command;

import sk.naive.talker.message.Category;
import sk.naive.talker.props.PropertyStoreException;

import java.rmi.RemoteException;

/**
 * User description command.
 *
 * @author <a href="mailto:virgo@naive.deepblue.sk">Richard "Virgo" Richter</a>
 * @version $Revision: 1.7 $ $Date: 2005/01/19 22:41:27 $
 */
public class Description extends OptionalParameterCommand {
	public static final String UPROP_DESCRIPTION = "description";
	public static final int MAX_LENGTH_WITH_NAME = 60;

	protected void execWithoutParameter() throws RemoteException {
		sendHelper().sendMessage(user, "description.is");
	}

	protected void execWithParameter() throws RemoteException, CommandException, PropertyStoreException {
		if ((params.length() + user.getLogin().length()) < MAX_LENGTH_WITH_NAME) {
			user.set(UPROP_DESCRIPTION, params);
			sendHelper().sendLocal(user, "description.you", "description.audience", Category.LOCAL);
		} else {
			sendHelper().sendMessage(user, "description.tooLong");
		}
	}
}
